#include <QStringList>
#include <QMessageBox>
#include "newarticle.h"
#include "ui_newarticle.h"

NewArticle::NewArticle(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::NewArticle)
{
    ui->setupUi(this);
}

NewArticle::~NewArticle()
{
    delete ui;
}

void NewArticle::on_no_clicked()
{
    this->close();
}

void NewArticle::on_yes_clicked()
{
    QStringList disable_string_list;
    disable_string_list << "'" << "\"";
    QString article_title = this->ui->article_line_edit->text();
    for (QString str : disable_string_list) {
        if (article_title.contains(str)) {
            QMessageBox::warning(this, "System Warning", "Article name has disabled substring.");
            return;
        }
    }
    this->ui->article_line_edit->setText("");
    emit this->send_article(article_title);
    this->close();
}
